﻿if not Exists(Select * from sysobjects where name = 'NewsLetterTrack' and xtype='U')
Begin
	
	Create Table dbo.NewsLetterTrack
	(
		[Id] [int] IDENTITY(1,1) NOT NULL,
		[CreationDate] [datetime] NOT NULL,
		[EventDate] [datetime] NOT NULL,
		[CampaingId] [int] NOT NULL,
		[Email] [nvarchar](200) NOT NULL,
		[LinkName] [nvarchar](200) NULL,
		[NewsLetterId] [int] NOT NULL,
		[UserId] [int] NOT NULL,
		[Ip] [nvarchar](40) NULL,
		[Url] [nvarchar](2048) NULL,
		[DestinationUrl] [nvarchar](2048) NULL,
		[EmailSentId] [int] NULL,
	)

	alter table dbo.NewsLetterTrack add constraint PK_NewsLetterTrack_Id primary key (Id)
	
	create index IX_NewsLetterTrack_Email on NewsLetterTrack (email)

	create index IX_NewsLetterTrack_NewsLetterId on NewsLetterTrack (NewsLetterId)

	create index IX_NewsLetterTrack_UserId on NewsLetterTrack (UserId)
End
Go